package com.jzo2o.customer.controller.worker;

import com.alibaba.nacos.api.model.v2.Result;
import com.jzo2o.common.utils.UserContext;
import com.jzo2o.customer.model.dto.request.AgencyCertificationAuditAddReqDTO;
import com.jzo2o.customer.service.IAgencyCertificationAuditService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

/**
 * @author: LiuLi
 * @Date: 2025/09/18 下午12:00
 * @Description: 机构认证审核控制器
 */
@RestController
@RequestMapping("/agency/agency-certification-audit")
@Api(tags = "机构端 - 机构认证审核相关接口")
public class AgencyCertificationAuditController {

    @Resource
    private IAgencyCertificationAuditService agencyCertificationAuditService;

    /**
     * 机构提交认证申请
     *
     * @param agencyCertificationAuditAddReqDTO 机构认证申请信息
     * @return 操作结果
     */
    @PostMapping
    @ApiOperation("机构提交认证申请")
    public Result<Boolean> add(@RequestBody AgencyCertificationAuditAddReqDTO agencyCertificationAuditAddReqDTO) {
        agencyCertificationAuditService.add(agencyCertificationAuditAddReqDTO);
        return Result.success(true);
    }

    /**
     * 查询申请失败原因
     *
     * @return 失败原因
     */
    @GetMapping("/rejectReason")
    @ApiOperation("查询申请失败原因")
    public Result<String> getRejectReason() {
        // 这里应该从当前登录用户获取机构ID
        // 假设当前登录用户是机构用户，直接返回失败原因
        // 实际项目中应该从UserContext或其他方式获取当前登录用户的ID
        Long serveProviderId = UserContext.currentUserId();
        String rejectReason = agencyCertificationAuditService.getRejectReason(serveProviderId);
        return Result.success(rejectReason);
    }
}